# import requests
from curl_cffi import requests
from bs4 import BeautifulSoup
import re
import json

# # 获取网页
# url = "http://books.toscrape.com/"
# response = requests.get(url)
#
# # 解析网页
# soup = BeautifulSoup(response.text, 'html.parser')
#
# # 查找所有书籍
# books = soup.find_all('h3')  # 书籍标题都在h3标签里
#
# print("找到的书籍:")
# for i, book in enumerate(books, 1):
#     book_title = book.a['title']  # 获取书名
#     print(f"{i}. {book_title}")



# qq_url = 'https://y.qq.com/'
# header = {
# 	'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36'
# }
#
# response = requests.get(qq_url,headers=header)
#
# soup = BeautifulSoup(response.text,'html.parser')
#
#
# list1 = soup.find_all('script')
#
# # print(list1[5])
# pattern = r'window\.__INITIAL_DATA__\s*=\s*({.*})'
# match = re.search(pattern, list1[5].text, re.S).group(1)
#
# fixed_json = re.sub(r':\s*undefined', ': null', match)
# data = json.loads(fixed_json)
# imgs = data['hotRecommend']
# print(imgs)
# for img in imgs:
# 	img_name = img['dissname']
# 	img_url = img['imgurl']
# 	img_response = requests.get(img_url)
# 	with open(f'static/{img_name}.jpeg','wb') as f:
# 		f.write(img_response.content)


# total = 0
# for i in range(1,21):
# 	url = f'https://www.mashangpa.com/api/problem-detail/1/data/?page={i}'
#
# 	header = {
# 		'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36',
# 		'referer': 'https://www.mashangpa.com/api/problem-detail/2/data/?page=1',
# 		'cookie': 'sessionid=3ps06cefdx786mg72qfsz415mk77gneg'
#
# 	}
#
# 	response = requests.get(url, headers=header)
#
# 	data = response.json()
# 	number = data['current_array']
# 	for j in  number:
# 		total += j
#
# print( total)

# total = 0
# for i in range(1, 21):
# 	url = f'https://www.mashangpa.com/api/problem-detail/2/data/?page={i}'
#
# 	header = {
# 		'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36',
# 		'referer': 'https://www.mashangpa.com/api/problem-detail/2/data/?page=1',
# 		'cookie': 'sessionid=3ps06cefdx786mg72qfsz415mk77gneg'
#
# 	}
#
# 	response = requests.get(url, headers=header)
#
# 	data = response.json()
# 	number = data['current_array']
# 	for j in number:
# 		total += j
#
# print(total)
 
 
# url = 'https://www.mashangpa.com//static/js/base.js'
#
# session = requests.Session()
#
# header = {
# 	'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36',
# 	'referer': 'https://www.mashangpa.com/problem-detail/3/',
# }
#
# response =  session.get(url,headers=header)
#
#
#
# print(response.text)


